
class Background extends egret.Sprite {
    public constructor() {
        super()
        this.setBg()
    }

    private stage_height: Number = 800
    private bg_speed: number = 2
    private bg_1: egret.Bitmap
    private bg_2: egret.Bitmap
    private setBg(): void {
        this.bg_1 = new egret.Bitmap()
        this.bg_2 = new egret.Bitmap()
        this.bg_1.texture = RES.getRes('tt_jpg')
        this.bg_2.texture = RES.getRes('tt_jpg')
        // 1 下 2 上
        this.bg_1.x = 0
        this.bg_1.y = 0

        this.bg_2.x = 0
        this.bg_2.y = -this.stage_height

        // this.bg_1.height = 100
        // this.bg_1.width = 100
        // this.bg_2.height = 100
        // this.bg_2.width = 100



        this.addChild(this.bg_1)
        this.addChild(this.bg_2)

        this.addEventListener(egret.Event.ENTER_FRAME, this.scrollEvent, this)
    }

    private scrollEvent(): void {
        
        this.bg_1.y += this.bg_speed
        this.bg_2.y += this.bg_speed

        if(this.bg_2.y >= 0) {
            this.bg_2.y = -this.stage_height
            this.bg_1.y = 0
        }
    }
}